<?php
session_start();
require_once ( 'inc/function.php' );

$smarty = new Smarty;

$DB = NewADOConnection('mysql');
$DB->Connect('localhost', $sql_user, $sql_pass, $sql_dbase);

if(array_key_exists('submit', $_POST)){

  $login = strip_tags(trim($_POST['login']));
  $pass = strip_tags(trim($_POST['pass']));

  $auth = $DB->GetOne("SELECT COUNT(*)FROM users WHERE login='$login' AND pass='".md5($pass)."'");

  if ($auth=='1'){
    $_SESSION['login'] = $login;
    $_SESSOON['auth'] = 'yes';
    header("Location: start.php");
  }
}

$self = basename($_SERVER['PHP_SELF']);

$smarty->assign('self', $self);
$smarty->display('index.tpl');

?>